package com.ztgf.sys.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ztgf.sys.common.config.YmlConfig;
import com.ztgf.sys.mapper.SysNoticeMapper;
import com.ztgf.sys.models.bo.SysNoticeBO;
import com.ztgf.sys.models.bo.SysNoticeSaveBO;
import com.ztgf.sys.models.dto.SysNoticeDTO;
import com.ztgf.sys.models.service.ISysNoticeService;
import com.ztgf.sys.models.vo.SysNoticeVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * 发送信息布告表控制器
 *
 * @author liyqng
 * @Date 2021-05-13 17:03:03
 */
@DubboService
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNoticeDTO> implements ISysNoticeService{

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public boolean add(SysNoticeSaveBO saveBO) {
        SysNoticeDTO dto = new SysNoticeDTO();
        BeanUtils.copyProperties(saveBO,dto);
        Long id = ymlConfig.getPkId();
        dto.setId(id);
        return this.insert(dto);
    }

    /**
     * 批量条件查询发布消息
     * @param bo
     * @return
     */
    @Override
    public Page<SysNoticeVO> queryPageList(SysNoticeBO bo) {
        Page<SysNoticeVO> page = new Page<>(bo.getPageNo(), bo.getPageSize());
        List<SysNoticeVO> vos = baseMapper.queryPageList(page, bo);
        page.setRecords(vos);
        return page;
    }

}
